package com.leetcode.LC;

import java.util.HashMap;
import java.util.Map;

public class LC167 {

    public int[] twoSum(int[] numbers, int target) {

        int[] ints = new int[2];
        int i=0;
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int num : numbers) {
            if(!map.containsKey(target-num)){
                map.put(num,i);
            }else {
                ints[0]=map.get(target-num)+1;
                ints[1]=i+1;
            }
            i++;
        }
        return ints;
    }

    public static void main(String[] args) {
        for (int i : new LC167().twoSum(new int[]{2, 7, 11, 15}, 9)) {
            System.out.println(i);
        }
    }
}
